var massage=["请输入原密码","请输入密码","请输入确认密码","两次密码不一致","密码只能是6至12的非汉字字符"];
//获取用户名和角色
function update(){
	var oldpass= $("#oldpass").val();
	var newpass = $("#newpass").val();
	var repass = $("#repass").val()
	if(oldpass=""){
		mui.alert(massage[0],"错误提示","确认",function(){
			$("#oldpass").focus();
		});
		return;
	}
	if(newpass==""){
		mui.alert(massage[1],"错误提示","确认",function(){
			$("#newpass").focus();
		});
		return;
	}
	if(repass==""){
		mui.alert(massage[2],"错误提示","确认",function(){
			$("#repass").focus();
		});
		return;
	}
	
	
	$.proAjax({
		url:"/mobile/checkpass",
		data:{oldpass:$("#oldpass").val()},
		dataType:"text",
		success:function(data){
			if(data){
				if(newpass==repass){
					checkpass(newpass);
				}else{
					mui.alert(massage[3],"错误提示","确认",function(){
						$("#repass").focus();
					});
				}
			}else{
				mui.alert("原密码输入有误","错误提示","确认",function(){
					$("#oldpass").val("");
					$("#oldpass").focus();
				});
			}
		}
	});
}
$("#newpass").blur(function(){
	newpass = $("#newpass").val();
	var reg=/^[^\u4e00-\u9fa5]{6,12}$/;
	if(!reg.test(newpass)){
		mui.alert(massage[4],"错误提示","确认",function(){
			$("#newpass").focus();
		});
	}
});
//修改密码
function checkpass(pass){
	$.proAjax({
		url:"/mobile/updatepw",
		data:{"newpass":pass},
		dataType:"text",
		success:function(data){
			localStorage.setItem('username',"");
			localStorage.setItem('password',"");
			logSrv.logout();
		}
	});
}
